package com.csust.automaticteach.model.enums;


import lombok.Getter;
import org.apache.commons.lang3.ObjectUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 生成教学内容在状态枚举
 */
@Getter
public enum GenerateQuestionStatusEnum {

    //    （1 草稿/2已发布/3下架/4等待中/5生成中/6失败
    DRAFT("草稿", 1),
    PUBLISHED("已发布", 2),
    OFF_SHELF("下架", 3),
    WAITING("等待中", 4),
    RUNNING("生成中", 5),
    FAILED("失败", 6);

    private final String text;
    private final Integer value;

    GenerateQuestionStatusEnum(String text, Integer value) {
        this.text = text;
        this.value = value;
    }

    /**
     * 获取值列表
     *
     * @return
     */
    public static List<Integer> getValues() {
        return Arrays.stream(values()).map(item -> item.value).collect(Collectors.toList());
    }

    /**
     * 根据 value 获取枚举
     *
     * @param value
     * @return
     */
    public static GenerateQuestionStatusEnum getEnumByValue(Integer value) {
        if (ObjectUtils.isEmpty(value)) {
            return null;
        }
        for (GenerateQuestionStatusEnum anEnum : GenerateQuestionStatusEnum.values()) {
            if (anEnum.value.equals(value)) {
                return anEnum;
            }
        }
        return null;
    }


}
